/**
 * 抽象类
 */

abstract class Component<T1, T2> {
  props: T1;
  state: T2;

  constructor(props: T1) {
    this.props = props;
  }

  // render(): string {
  //   return '';
  // }
  /**
   * 1、抽象类里不能有实体
   * 2、抽象类不能实例化
   */
  abstract render(): string;

}

interface IMyComponentProps {
  val: number;
}

interface IMyComponentState {
  x: number;
}

class MyComponent extends Component<IMyComponentProps, IMyComponentState> {
  constructor(props: IMyComponentProps) {
    super(props);
    this.state = {
      x: 1
    }
  }

  render() {
    console.log(this.props.val);
    console.log(this.state.x);
    return '<MyComponent />';
  }
}

let myComponent = new MyComponent({ val: 1 });
myComponent.render();